home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / tools / jade / src / x11_windowsys.h < prev   
C/C++ Source or Header  |  1995-03-09  |  3KB  |  108 lines

  1. /* x11_windowsys.h -- X11 window-system data and macros
  2.    Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4.    This file is part of Jade.
  5.  
  6.    Jade is free software; you can redistribute it and/or modify it
  7.    under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    Jade is distributed in the hope that it will be useful, but
  12.    WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with Jade; see the file COPYING.  If not, write to
  18.    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef _X11_WINDOWSYS_H
  21. #define _X11_WINDOWSYS_H
  22.  
  23. typedef struct {
  24.     Window        ws_Window;
  25.     GC            ws_TextFontGC, ws_BlkFontGC;
  26.     int            ws_PenX, ws_PenY;
  27.     XFontStruct           *ws_Font;
  28.     int            ws_Width, ws_Height;
  29. } VW_WindowSys;
  30.  
  31. #define vw_Window    vw_WindowSys.ws_Window
  32. #define vw_Font        vw_WindowSys.ws_Font
  33. #define WINDOW_NIL    (0)
  34.  
  35. #if 0
  36. typedef struct {
  37.     /* ... */
  38. } ScrollBar;
  39. #endif
  40.  
  41. /* Pen colours. */
  42. #define P_TEXT    0
  43. #define P_BLOCK 1
  44.  
  45. /*
  46.  * Macros for drawing operations. These are mainly used in render.c for
  47.  * system-independant rendering.
  48.  */
  49.  
  50. /* Move to position (X,Y). The next DRAW() will happen at this position. */
  51. #define MOVE(vw,x,y) \
  52.     do { \
  53.     (vw)->vw_WindowSys.ws_PenX = (x); \
  54.     (vw)->vw_WindowSys.ws_PenY = (y); \
  55.     } while(0)
  56.  
  57. #define PEN_X(vw) ((vw)->vw_WindowSys.ws_PenX)
  58. #define PEN_Y(vw) ((vw)->vw_WindowSys.ws_PenY)
  59.  
  60. /* Draw LEN bytes of the string STR with colour COL (P_TEXT or P_BLOCK)
  61.    at the position set by the MOVE() macro.  */
  62. #define TEXT(vw,col,str,len) \
  63.     do { \
  64.     XDrawImageString(x11_display, (vw)->vw_Window, \
  65.              ((col) == P_TEXT) \
  66.               ? (vw)->vw_WindowSys.ws_TextFontGC \
  67.               : (vw)->vw_WindowSys.ws_BlkFontGC, \
  68.              (vw)->vw_WindowSys.ws_PenX, (vw)->vw_WindowSys.ws_PenY, \
  69.              (str), (len)); \
  70.     (vw)->vw_WindowSys.ws_PenX += (len) * vw->vw_FontX; \
  71.     } while(0)
  72.  
  73. /* Clear a rectangle from (X,Y) to (X+W,Y+H).  */
  74. #define CLR_AREA(vw,x,y,w,h) \
  75.     XClearArea(x11_display, (vw)->vw_Window, (x), (y), (w), (h), False)
  76.  
  77. #define CLR_RECT(vw,x1,y1,x2,y2) \
  78.     XClearArea(x11_display, (vw)->vw_Window, (x1), (y1), \
  79.            (x2) - (x1), (y2) - (y1), False)
  80.  
  81. /* Fill a rectangle from (X,Y) to (X+W,Y+H).  */
  82. #define SET_AREA(vw,x,y,w,h) \
  83.     XFillRectangle(x11_display, (vw)->vw_Window, (vw)->vw_WindowSys.ws_TextFontGC, \
  84.            (x), (y), (w), (h))
  85.  
  86. #define SET_RECT(vw,x1,y1,x2,y2) \
  87.     XFillRectangle(x11_display, (vw)->vw_Window, (vw)->vw_WindowSys.ws_TextFontGC, \
  88.            (x1), (y1), (x2) - (x1), (y2) - (y1))
  89.  
  90. /* Copy pixels from (X1,Y1),(X1+W,Y1+H) to (X2,Y2)  */
  91. #define COPY_AREA(vw,x1,y1,w,h,x2,y2) \
  92.     do { \
  93.     XCopyArea(x11_display, (vw)->vw_Window, (vw)->vw_Window, \
  94.           (vw)->vw_WindowSys.ws_TextFontGC, \
  95.           (x1), (y1), (w), (h), (x2), (y2)); \
  96.     x11_handle_gexposures(vw); \
  97.     } while(0)
  98.  
  99. /* Number of pixels from top of font to its baseline.  */
  100. #define FONT_ASCENT(vw) ((vw)->vw_Font->ascent)
  101.  
  102. /* Draw a line from (x1,y1) to (x2,y2)  */
  103. #define DRAW_LINE(vw,x1,y1,x2,y2) \
  104.     XDrawLine(x11_display, vw->vw_Window, vw->vw_WindowSys.ws_TextFontGC, \
  105.           x1, y1, x2, y2)
  106.  
  107. #endif /* _X11_WINDOWSYS_H */
  108.